package com.example.yiqiuser.controller;

import com.example.yiqiuser.entity.Season;
import com.example.yiqiuser.service.SeasonService;
import com.example.yiqiuser.util.Page;
import com.example.yiqiuser.util.Result;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * @create by: 周文达 (3220083246@qq.com)
 * @description:
 * @create time: 2023/4/12 22:41
 * @return
 */
@RestController
@RequestMapping("season")
public class SeasonController extends BaseController{
@Resource//依赖注入
private SeasonService seasonService;

    /**
     * 分页带参查询
     * @param page
     * @return
     */
    @PostMapping("queryPage")
public Result queryPage(@RequestBody Page<Season> page){
    return success(seasonService.queryPage(page));
}

    /**
     * 查询全部
     * @return
     */
    @PostMapping("queryAll")
public  Result queryAll(){
    return success(seasonService.queryAll());
}

    /**
     * 根据id查询
     * @param code
     * @return
     */
    @GetMapping("queryById")
public Result queryById(Integer code){
    return success(seasonService.queryById(code));
}

    /**
     * 添加
     * @param season
     * @return
     */
    @PostMapping("add")
    public  Result add(@RequestBody Season season){
        return success(seasonService.add(season));
    }

    /**
     * 更改
     * @param season
     * @return
     */
    @PostMapping("update")
    public Result update(@RequestBody Season season){
        return success(seasonService.update(season));
    }

    /**
     * 根据id删除
     * @param code
     * @return
     */
    @GetMapping("deleteById")
    public Result deleteById(Integer code){
        return success(seasonService.deleteById(code));
    }
}
